package com.example.demo.springboot.consumer;

import com.example.demo.springboot.mqclient.consumer.MqConsumerConstant;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
 * DirectConsumer:路由模式
 *
 * @author zhangxiaoxiang
 * @date 2020/11/16
 */
@Component
@Slf4j
public class DirectConsumer {

    @RabbitListener(bindings = {
            @QueueBinding(
                    exchange = @Exchange(name = MqConsumerConstant.DIRECT_CALLLOG_EXCHANGE),
                    value = @Queue(name = MqConsumerConstant.DIRECT_CRM_CALLLOG_QUEUE),
                    key = MqConsumerConstant.DIRECT_CRM_CALLLOG_KEY
            )
    })
    public void crmListener(String msg) {
        log.info("crm系统收到外呼话单回调[执行业务逻辑]:{}", msg);
    }

    @RabbitListener(bindings = {
            @QueueBinding(
                    exchange = @Exchange(name = MqConsumerConstant.DIRECT_CALLLOG_EXCHANGE),
                    value = @Queue(name = MqConsumerConstant.DIRECT_ZHIYU_CALLLOG_QUEUE),
                    key = MqConsumerConstant.DIRECT_ZHIYU_CALLLOG_KEY
            )
    })
    public void zhiYuListener(String msg) {
        log.info("zhiYu系统收到外呼话单回调[执行业务逻辑]:{}", msg);
    }
}
